package com.songlanyun.modules.rights.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.songlanyun.common.validator.ValidatorUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.Query;

import com.songlanyun.modules.rights.dao.RightsOrderOperateRecordDao;
import com.songlanyun.modules.rights.entity.RightsOrderOperateRecord;
import com.songlanyun.modules.rights.service.RightsOrderOperateRecordService;


@Service("rightsOrderOperateRecordService")
public class RightsOrderOperateRecordServiceImpl extends ServiceImpl<RightsOrderOperateRecordDao, RightsOrderOperateRecord> implements RightsOrderOperateRecordService {

    @Override
    public RightsOrderOperateRecord create(RightsOrderOperateRecord entity) {
        ValidatorUtils.validateEntity(entity);
        this.baseMapper.insert(entity);
        return entity;
    }

    @Override
    public RightsOrderOperateRecord modify(RightsOrderOperateRecord entity) {
        ValidatorUtils.validateEntity(entity);
        this.baseMapper.updateById(entity);
        return entity;
    }

    @Override
    public void remove(Long id) {

    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<RightsOrderOperateRecord> page = this.page(
                new Query<RightsOrderOperateRecord>().getPage(params),
                new QueryWrapper<RightsOrderOperateRecord>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<RightsOrderOperateRecord> loadRightsOrderOperateRecords(Long rightsOrderId) {
        return this.list(new LambdaQueryWrapper<RightsOrderOperateRecord>()
                .eq(RightsOrderOperateRecord::getRightsOrderId,rightsOrderId));
    }

}